<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>作品地带</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/main.css" />
    <link rel="stylesheet" type="text/css" href="../../css/myProduct.css" />
</head>
<body id="productBody">
  <div id="header">
    <div id="back"></div>
    <h3>我发布的通知</h3>
  </div>
  <div id="all" style="padding-bottom:58px;">
    <div class="notice_list">
    </div>
  </div>
  <footer>
    <button class="myBtn" onclick="openPage('create_notice','create_notice.html')">发布新通知</button>
  </footer>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.js"></script>
<script type="text/javascript">
function getNotice_list(){
  var url='/api/annunciates';
  var functionRet=function(ret){
    for (var i = 0; i < ret.length; i++) {
          $(".notice_list").prepend('<div class="list" id='+ret[i].id+'><div class="notice_content">'+ret[i].content+'</div><div class="notice_time">'+ret[i].createTime+'</div><button class="btn btn-o">删除</button></div>');
    }
  }
  var functionErr=function(err){
    return false;
  }
  get(url,functionRet,functionErr);
}
apiready=function(){
  getNotice_list();
}
//jquery
$(function(){
  back();
  //删除通知
  $("#all").on("click",".list .btn",function(){
    var url='/api/annunciates/'+$(this).parent().attr("id");
    var data=[];
    var functionRet=function(ret){
    }
    var functionErr=function(err){
      if(err.statusCode==200){
        toast("删除成功","middle");
        api.execScript({
          name: 'root',
          frameName: 'frame2',
          script: 'history.go(0)'
        });
        api.execScript({
            script: history.go(0)
        });

      }
    }
    deleteData(url,data,functionRet,functionErr);
  })
})
</script>
<script type="text/javascript" src="../../script/main.js"></script>
</html>
